package collection;

import java.util.ArrayList;
import java.util.List;

/**
 *List集合的演示：add()的重载，remove()的重载.   重载方式都是基于下标
 *
 * */
public class ListDemo2 {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("one");
        list.add("two");
        list.add("three");
        list.add("four");
        list.add("five");
        System.out.println("list"+list);
        list.add(2,"six");//在下标为2的位置插入six  最多在下标数加1插入
        System.out.println("list:"+list);//[one, two, six, three, four, five]
        list.add(3,"seven");
        System.out.println("list:"+list);
        list.add(7,"ten");
        System.out.println("list:"+list);
        list.remove(3);//删除下标为3的元素
        String s = list.remove(2);//删除下标为2的元素//这个无非就是把下标为2的元素删掉并把删掉的那个元素赋给s
        System.out.println("list:"+list);//[one, two, six, four, five]













    }
}
